package com.sa.controller;


import com.sa.bean.req.UserAddReq;
import com.sa.bean.vo.UserVO;
import com.sa.service.UserService;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@Slf4j
@RequiredArgsConstructor
@Validated
public class UserController {

    private final UserService userService;

    @GetMapping("/selectById")
    public UserVO selectById(@NonNull Long userId) {
        return userService.selectById(userId);
    }

    @PostMapping("/add")
    public String add(@RequestBody @Validated UserAddReq userAddReq) {
        userService.add(userAddReq.getUsername(), userAddReq.getPhone(), userAddReq.getFeatures());
        return "ok";
    }
}
